;Copyright Joshua Weberruss 2007

;This file is part of n-Shell.
;
;n-Shell is free software: you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation, either version 3 of the License, or
;(at your option) any later version.
;
;n-Shell is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License
;along with n-Shell.  If not, see <http://www.gnu.org/licenses/>.

;Include file for n-Shell v0.08: Runtime Library Functions, RAM Equates and constants

;Runtime Library (Usage: call [func. name])
;Display
nS_ClearScreen	.equ	$4083
nS_Present			.equ	$4086
nS_DispString		.equ	$4089
nS_ContString		.equ	$408C
nS_Sprite8			.equ	$408F
nS_BlackRect		.equ	$4092

;Keyboard
nS_WaitKey		.equ	$4095
nS_GetCursorKey	.equ	$4098

;Memory
nS_Malloc			.equ	$409B
nS_FreeLast		.equ	$409E

;String
nS_StrLen			.equ	$40A1
nS_StrCat			.equ	$40A4

;Utility
nS_GetStrPixLen	.equ	$40A7
nS_Delay			.equ	$40AA

;Integer Maths
nS_UIMult8			.equ	$40AD
nS_UIDiv8			.equ	$40B0
nS_UIMult16_8	.equ	$40B3
nS_SIMult8			.equ	$40B6
nS_SIDiv8			.equ	$40B9
nS_SIMult16_8	.equ	$40BC

;File I/O
nS_FOpen			.equ	$40BF
nS_FEOF			.equ	$40C2
nS_FLen				.equ	$40C5
nS_FGetC			.equ	$40C8
nS_FRead			.equ	$40CB
nS_FSeekA			.equ	$40CE
nS_FSeekR			.equ	$40D1

;DLL Interface
nS_LoadDLL		.equ	$40D4
nS_DLLCall			.equ	$40D7

;RAM Equates
;Shell Settings and Options
_save_sp			.equ	$C000
_save_mempages	.equ	$C002
_save_iy			.equ	$C004

;Global Variables
nShell_Rev			.equ	$C080
TextRow				.equ	$C082
TextCol				.equ	$C083
SpriteDrawMode	.equ	$C084

;Display
FrameBuffer 		.equ	$C100	;768 bytes

;OS Private (i.e. don't touch)
eFAT					.equ	$C400	;256 bytes (Executable File Allocation Table) (limit of 15 entries)
gFAT					.equ	$C500	;512 bytes (General File Allocation Table) (limit of 30 entries)
TempSave16A		.equ	$C700
TempSave16B		.equ	$C702
TempSave8A		.equ	$C704
TempSave8B		.equ	$C705
BlackRectPtr		.equ	$C706
ClearScreenSP		.equ	$C708
CurrentProgIndex	.equ	$C70A
eFATe				.equ	$C70B
gFATe				.equ	$C70D

FPtr0					.equ	$C70F
FPtr1					.equ	$C712
FPtr2					.equ	$C715
FPtr3					.equ	$C718
FPtr4					.equ	$C71B
FPtr5					.equ	$C71E
FPtr6					.equ	$C721
FPtr7					.equ	$C724
FPtr8					.equ	$C727
FPtr9					.equ	$C72A
FPtr10				.equ	$C72D
FPtr11				.equ	$C730
FPtr12				.equ	$C733
FPtr13				.equ	$C736
FPtr14				.equ	$C739
FPtr15				.equ	$C73C
FPtr16				.equ	$C73F
FPtr17				.equ	$C742
FPtr18				.equ	$C745
FPtr19				.equ	$C748
FPtr20				.equ	$C74B
FPtr21				.equ	$C74E
FPtr22				.equ	$C751
FPtr23				.equ	$C754
FPtr24				.equ	$C757
FPtr25				.equ	$C75A
FPtr26				.equ	$C75D
FPtr27				.equ	$C760
FPtr28				.equ	$C763
FPtr29				.equ	$C766

ErrorHandler		.equ	$C769

DLLCallSaveBC		.equ	$C76B
DLLCallSaveDE		.equ	$C76D
DLLCallSaveHL		.equ	$C76F
DLLCallSaveJP		.equ	$C771

CurrentModRef		.equ	$C773

;Memory
LongTerm			.equ	$C800	;4k bytes (256 16-byte blocks, reservable: e-mail me for 1+)
HeapPool			.equ	$D800	;8k bytes
Stack				.equ	$F800	;This leaves 512b of memory which will always be free for the stack's use, but it can
											;overflow into the heap pool, which might mess stuff up.

;Constants
;DisplayModes
DM_Standard		.equ	0			;or
DM_Invert			.equ	1			;xor
DM_UnderMask	.equ	2			;and

;FileTypes
FT_General			.equ	0			;standard, garden variety file
FT_StdExe			.equ	1			;standard executable file, either exe or dll (it doesn't matter which)

;System Errors
E_FileNotFound	.equ	$10
E_InvalidFileIndex	.equ	$11

;Structures
;EXERef ;Dynamic-Link-Library Reference
#define EXERef.Page		(iy+0)
#define EXERef.BaseLSB	(iy+1)
#define EXERef.BaseMSB	(iy+2)
#define EXERef.LenLSB		(iy+3)
#define EXERef.LenMSB		(iy+4)